<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%issue}}`.
 */
class m240307_074609_create_issue_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%issue}}', [
            'id' => $this->primaryKey(),

            'projectId' => $this->integer()->notNull(),
            'contactId' => $this->integer()->notNull(),
            
            'name' => $this->string(),
            'detail' => $this->text(),
            'priority' => $this->integer()->defaultValue(1)->comment('start counts, max to 3'),
            'state' => $this->integer()->defaultValue(0)->comment('0 for new, 1 for working on it, 2 for suspended, 3 for finished, 10 for deleted'),
            'date' => $this->date()->comment('request date'),

            'createdAt' => $this->datetime()->defaultExpression('CURRENT_TIMESTAMP'),
            'updatedAt' => $this->datetime()->defaultExpression('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'),
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%issue}}');
    }
}
